/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package br.siagefi.service;

import br.siagefi.dao.DAO;
import br.siagefi.model.FornecedorPJ;
import java.util.List;

/**
 *
 * @author NOTE
 */
public class FornecedorPJService {
    private final DAO<FornecedorPJ> dao;

    public FornecedorPJService() {
        this.dao = new DAO<>(FornecedorPJ.class);
    }
    
    public void inserir(FornecedorPJ fornecedor){
        dao.adiciona(fornecedor);
    }
    
    public void alterar(FornecedorPJ fornecedor){
        dao.atualiza(fornecedor);
    }
    
    public List<FornecedorPJ> listar(){
        return dao.listaTodos();
    }
    
    public void remover(FornecedorPJ fornecedorPJ){
        dao.remove(fornecedorPJ);
    }
    
    public boolean jaExiste(FornecedorPJ fornecedor) {
        List<FornecedorPJ> lista = this.listar();
        for (FornecedorPJ f : lista) 
            if(f.equals(fornecedor))
                return true;
        return false;
    }
}
